package com.itwn.portal.mapper;

import com.itwn.portal.entity.Score;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface ScoreMapper {
    int deleteByPrimaryKey(Integer resourceId);

    void insert(Score record);

    Score selectByPrimaryKey(Integer resourceId);

    List<Score> selectAll();

    int updateByPrimaryKey(Score record);

    @Select("select avg(point) as rscore from t_score where resource_id = #{rid}")
    Double selectAvgById(@Param("rid")Integer rid);

    @Select("select point as myscore from t_score where resource_id = #{rid} and user_id= #{uid}")
    Double selectMyScore(@Param("rid")int rid,@Param("uid")int uid);

    @Select("select count(*) from t_score where resource_id = #{rid}")
    int selectVoteNum(@Param("rid")Integer rid);
}